package com.chen.servlet;/*
package com.chen.servlet;

import com.chen.entity.FlightEntity;
import com.chen.entity.UserEntity;
import com.chen.service.FlightService;
import com.chen.service.UserService;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.List;

//控制层
@WebServlet("/showFlight")
public class ShowFlightServlet extends HttpServlet {
    private FlightService flightService = new FlightService();
    private UserService userService = new UserService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost
            (HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        //1、控制层调用业务逻辑层获取数据
        String phone = req.getParameter("phone");
        String departureAirport = req.getParameter("departureAirport");
        String arriveAirport = req.getParameter("arriveAirport");
        List<FlightEntity> flightEntities = null;
        if((departureAirport == null || departureAirport == "") &&
                (arriveAirport == null || arriveAirport == "")){
            flightEntities = flightService.getByAll();
        }else{
            flightEntities = flightService.searchByAll(departureAirport, arriveAirport);
        }
        UserEntity userEntity = userService.getByPhoneUser(phone);
        if(userEntity.getId() == 1){
            //2、转发到jsp中
            //管理员登陆
            req.setAttribute("flightEntities", flightEntities);
            req.setAttribute("userEntity", userEntity);
            req.getRequestDispatcher("showRoot.jsp").forward(req, resp);
        }else{
            //2、转发到jsp中
            //普通用户登陆
            req.setAttribute("flightEntities", flightEntities);
            req.setAttribute("userEntity", userEntity);
            req.getRequestDispatcher("showUser.jsp").forward(req, resp);
        }
    }
}
*/
